package com.example.qxfw.common.util;
/**
 * 天气信息转换工具
 */
public  class WeatherInfoUtil {
    /**
     *预测级别
     */
    public static int getForecastLevel(String strWeather) {
        int iLevel = 0;

        if (strWeather.contains("大雪") || strWeather.contains("中雪") || strWeather.contains("大雨") || strWeather.contains("暴雨")
                || strWeather.contains("强沙尘暴") || strWeather.contains("雾") || strWeather.contains("雷阵雨")) {
            iLevel = 5;
        } else if (strWeather.contains("阵雨") || strWeather.contains("雪") || strWeather.contains("中雨")) {
            iLevel = 4;
        } else if (strWeather.contains("小雨") || strWeather.contains("扬沙")) {
            iLevel = 3;
        } else if (strWeather.contains("阴")) {
            iLevel = 2;
        } else if (strWeather.contains("晴") || strWeather.contains("多云")) {
            iLevel = 1;
        }

        return iLevel;
    }

    /**
     * 风向
     */
    public static String getFX(double FX)
    {
        String fx = "北风";
        if (FX >= 22.5 && FX < 67.5)
        {
            fx = "东北风";
        }
        else if (FX >= 67.5 && FX < 112.5)
        {
            fx = "东风";
        }
        else if (FX >= 112.5 && FX < 157.5)
        {
            fx = "东南风";
        }
        else if (FX >= 157.5 && FX < 202.5)
        {
            fx = "南风";
        }
        else if (FX >= 202.5 && FX < 247.5)
        {
            fx = "西南风";
        }
        else if (FX >= 247.5 && FX < 292.5)
        {
            fx = "西风";
        }
        else if (FX >= 292.5 && FX < 337.5)
        {
            fx = "西北风";
        }
        else if (FX >= 337.5 || FX < 22.5)
        {
            fx = "北风";
        }
        return fx;
    }

    /**
     * 级别信息说明
     */
    public static String getLevelExplain(int iLevle)
    {
        String text = "";
        switch (iLevle)
        {
            case 1:
                text = "路面状况良好，能见度好，对交通无影响";
                break;
            case 2:
                text = "比较安全，路面较好，能见度一般,对交通影响不大，可以正常行驶";
                break;
            case 3:
                text = "基本安全，路况较差，对交通有影响，司机注意观察前方路况，减速慢行";
                break;
            case 4:
                text = "不太安全，路面状况差，对交通有严重影响，尽量减少车辆出行，司机应注意避让行人，减速慢行,谨慎驾驶";
                break;
            case 5:
                text = "不安全，路况极差，对交通有严重影响，尽量减少车辆出行，各种车辆要限速行驶车辆行驶困难";
                break;
            default:
                break;
        }
        return text;
    }

    /**
     * 摩擦系数
     */
    public static String getForecastMCXS(String strWeather)
    {
        String MCXS = "";
        if (strWeather.indexOf("晴") >= 0 || strWeather.indexOf("多云") >= 0)
        {
            MCXS = "0.7";
        }
        if (strWeather.indexOf("阴") >= 0 || strWeather.indexOf("雾") >= 0)
        {
            MCXS = "0.5";
        }
        else if (strWeather.indexOf("雨") >= 0 || strWeather.indexOf("雪") >= 0)
        {
            MCXS = "0.3";
        }
        return MCXS;
    }

    /**
     * 风处理方法
     * @param fengsu
     * @return
     */
    public static int fengSuToFengJi(double fengsu) {
        if (fengsu >= 0 && fengsu <= 3.3) {
            return 0;
        } else if (fengsu <= 5.5) {
            return 1;
        } else if (fengsu <= 7.9) {
            return 2;
        } else if (fengsu <= 10.7) {
            return 3;
        } else if (fengsu <= 13.8) {
            return 4;
        } else if (fengsu <= 17.1) {
            return 5;
        } else if (fengsu <= 20.7) {
            return 6;
        } else if (fengsu <= 24.4) {
            return 7;
        } else if (fengsu <= 28.4) {
            return 8;
        } else if (fengsu > 28.4) {
            return 9;
        }
        return 0;
    }

    /**
     * 得到风级信息
     * @param strFs
     * @return
     */
    public static String GetWeatherFs(String strFs) {
        if (strFs.contains("级"))
            return strFs;
        strFs = strFs.trim();
        if (strFs.isEmpty()) {
            strFs = "0";
        } else {
            if (Integer.parseInt(strFs) >= 10) {
                strFs = String.valueOf(Double.parseDouble(strFs) / 10);
            }
        }

        try {
            switch (strFs) {
                case "0":
                    strFs = "≤3级";
                    break;
                case "1":
                    strFs = "3到4级";
                    break;
                case "2":
                    strFs = "4到5级";
                    break;
                case "3":
                    strFs = "5到6级";
                    break;
                case "4":
                    strFs = "6到7级";
                    break;
                case "5":
                    strFs = "7到8级";
                    break;
                case "6":
                    strFs = "8到9级";
                    break;
                case "7":
                    strFs = "9到10级";
                    break;
                case "8":
                    strFs = "10到11级";
                    break;
                case "9":
                    strFs = "11到12级";
                    break;
                default:
                    break;
            }
            return strFs;
        } catch (Exception e) {
            return "0";
        }
    }

}
